<<<<<<< HEAD
<?php
/**
 * 后台用户留言
 * @author Administrator
 *
 */
class Leaveword extends CI_Controller {
	/**
	 * 登陆验证
	 */
	
	private $tab = 'user';
	
	function __construct(){
		parent::__construct();
		$this->load->library('session');
			
		$admin = $this->session->userdata('admin_user');
		if(!$admin || !isset($admin['user_id'])){
			header('Location: /sys_admin/login');
			exit;
		}
	}
		
	   public function logout(){
				$this->session->set_userdata('rsh_user','');
				$this->js->go('/login');
	   }
			   
	   /**
	    * 后台留言列表 
	    */
	    function background_leaveword_list(){
		    $per_page  = intval($this->input->get('per_page')?$this->input->get('per_page'):0);
			$username  = $this->input->get('username');	
			$title 	   = $this->input->get('title');	
		  
			$data = array();
		    if($username != ''){
				$data['where']['username'] = $username;
			}
			if($title != ''){
				$data['where']['title'] = $title;
			}
			
			$data['page_size']  = sys_admin_LIST_PAGE_SIZE;
			$data['page_start'] = $per_page;
			$this->load->model('Leaveword_model','leaveword');
			$data = $this->leaveword->background_leaveword_list($data);
			
			//分页
			$this->load->library('pagination');
			$config['base_url'] = '/sys_admin/leaveword/background_leaveword_list?username='.$username.'&title='.$title;
			$config['total_rows'] = $data['leaveword_count'];
			$config['per_page'] = sys_admin_LIST_PAGE_SIZE; 
			$this->pagination->initialize($config); 
			
			$data['tab'] = $this->tab;
		    $data['sub'] = 'leaveword';
		
			$this->load->view('/sys_admin/user/leaveword_list', $data);
	   }
	   
	   /**
	    * 删除留言
	    */
	   function remove(){
	   	    $id 			= $this->input->post('id');
	   		$data["is_del"]	= 1;
	   		$this->load->model('Leaveword_model');
			echo $this->Leaveword_model->remove($id, $data);
	   }
	   
		/**
		 *显示留言
		 */
		function show_leaveword($leaveword_id){
				$this->load->model('Leaveword_model');
		  		$leaveword = $this->Leaveword_model->show_leaveword($leaveword_id);
		  		$vdata['leaveword'] = $leaveword;
		  		
		  		$vdata['tab'] = $this->tab;
		        $vdata['sub'] = 'leaveword';
		        
		  		$this->load->view("/sys_admin/user/leaveword_view", $vdata);
		}
		
		/**
		 * 显示回复留言
		 */
		function show_reply_leaveword($leaveword_id){
			    $this->load->model('Leaveword_model');
		  		$leaveword = $this->Leaveword_model->show_reply_leaveword($leaveword_id);
		  		$vdata['leaveword'] = $leaveword;
		  		
		  		$vdata['tab'] = $this->tab;
		        $vdata['sub'] = 'leaveword';
		    
		  		$this->load->view("/sys_admin/user/leaveword_reply", $vdata);
		}
		
		/**
		 * 回复留言
		 */
		function reply_leaveword($id){
			$user = $this->session->userdata('rsh_user');
			$user_id = $user['user_id'];
			$act = $this->input->post('act');
			if($act == 'submit'){
				$ret = array('msg'=>'','url'=>'');
				$title = $this->input->post('reply_content');
				if ($title =="" ){
					$ret['msg'] = '回复内容不能为空';
					echo json_encode($ret);
					exit;
				}
				
				$data = array(
					'reply_user'   => $user['user_id'],
					'reply_time'  	  => time(),
					'reply_content'   => trim($this->input->post("reply_content")),
				);
				$this->load->model('Leaveword_model','leaveword');
				$this->leaveword->reply_leaveword($id,$data);
				echo json_encode($ret);exit;
			}	
		}
}

=======
<?php
/**
 * 后台用户留言
 * @author Administrator
 *
 */
class Leaveword extends CI_Controller {
    /**
	 * 登陆验证
	 */
	
	private $tab = 'user';
	
	function __construct(){
		parent::__construct();
		$this->load->library('session');
			
		$admin = $this->session->userdata('admin_user');
		if(!$admin || !isset($admin['user_id'])){
			header('Location: /sys_admin/login');
			exit;
		}
	}
		
	   public function logout(){
				$this->session->set_userdata('rsh_user','');
				$this->js->go('/login');
	   }
			   
	   /**
	    * 后台留言列表 
	    */
	    function background_leaveword_list(){
		    $per_page  = intval($this->input->get('per_page')?$this->input->get('per_page'):0);
			$username  = $this->input->get('username');	
			$title 	   = $this->input->get('title');	
		  
			$data = array();
		    if($username != ''){
				$data['where']['username'] = $username;
			}
			if($title != ''){
				$data['where']['title'] = $title;
			}
			
			$data['page_size']  = sys_admin_LIST_PAGE_SIZE;
			$data['page_start'] = $per_page;
			$this->load->model('Leaveword_model','leaveword');
			$data = $this->leaveword->background_leaveword_list($data);
			
			//分页
			$this->load->library('pagination');
			$config['base_url'] = '/sys_admin/leaveword/background_leaveword_list?username='.$username.'&title='.$title;
			$config['total_rows'] = $data['leaveword_count'];
			$config['per_page'] = sys_admin_LIST_PAGE_SIZE; 
			$this->pagination->initialize($config); 
			
			$data['tab'] = $this->tab;
		    $data['sub'] = 'leaveword';
		
			$this->load->view('/sys_admin/user/leaveword_list', $data);
	   }
	   
	   /**
	    * 删除留言
	    */
	   function remove(){
	   	    $id 			= $this->input->post('id');
	   		$data["is_del"]	= 1;
	   		$this->load->model('Leaveword_model');
			echo $this->Leaveword_model->remove($id, $data);
	   }
	   
		/**
		 *显示留言
		 */
		function show_leaveword($leaveword_id){
				$this->load->model('Leaveword_model');
		  		$leaveword = $this->Leaveword_model->show_leaveword($leaveword_id);
		  		$vdata['leaveword'] = $leaveword;
		  		
		  		$vdata['tab'] = $this->tab;
		        $vdata['sub'] = 'leaveword';
		        
		  		$this->load->view("/sys_admin/user/leaveword_view", $vdata);
		}
		
		/**
		 * 显示回复留言
		 */
		function show_reply_leaveword($leaveword_id){
			    $this->load->model('Leaveword_model');
		  		$leaveword = $this->Leaveword_model->show_reply_leaveword($leaveword_id);
		  		$vdata['leaveword'] = $leaveword;
		  		
		  		$vdata['tab'] = $this->tab;
		        $vdata['sub'] = 'leaveword';
		    
		  		$this->load->view("/sys_admin/user/leaveword_reply", $vdata);
		}
		
		/**
		 * 回复留言
		 */
		function reply_leaveword($id){
			$user = $this->session->userdata('rsh_user');
			$user_id = $user['user_id'];
			$act = $this->input->post('act');
			if($act == 'submit'){
				$ret = array('msg'=>'','url'=>'');
				$title = $this->input->post('reply_content');
				if ($title =="" ){
					$ret['msg'] = '回复内容不能为空';
					echo json_encode($ret);
					exit;
				}
				
				$data = array(
					'reply_user'   => $user['user_id'],
					'reply_time'  	  => time(),
					'reply_content'   => trim($this->input->post("reply_content")),
				);
				$this->load->model('Leaveword_model','leaveword');
				$this->leaveword->reply_leaveword($id,$data);
				echo json_encode($ret);exit;
			}	
		}
}

>>>>>>> d47623b610d79a4eeb489500830c00d70933f414
?>